<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>eos-Wallet API</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="./plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="./plugins/layui/css/myPage.css">
</head>
<body style="overflow-x:hidden;">
<div class=" layui-show">
    <div class="layui-container">
        <div class="layui-row">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>创建新的钱包</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">钱包名称</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="name1" class="layui-input">
                        </div>
                        <button type="button" class="layui-btn layui-btn-normal" id="create">创建钱包</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">密码</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="mima" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>打开给定名称的现有钱包</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">钱包名称</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="name2" class="layui-input">
                        </div>
                        <button type="button" class="layui-btn layui-btn-normal" id="open">打开钱包</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">钱包</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="qianbao" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>锁定给定名称的钱包</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">钱包名称</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="name3" class="layui-input">
                        </div>
                        <button type="button" class="layui-btn layui-btn-normal" id="lock">锁定钱包</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">钱包</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="qianbao2" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>锁定所有钱包</legend>
                    <div class="layui-form-item">
                        <button type="button" class="layui-btn layui-btn-normal" id="lock_all">锁定所有钱包</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">钱包</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="qianbao3" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>用给定的名称和密码解锁钱包</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">钱包名称</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="name4" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">钱包密码</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="mima2" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <button type="button" class="layui-btn layui-btn-normal" id="unlock">解锁钱包</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">钱包</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="qianbao4" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>将私钥导入给定名称的钱包</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">钱包名称</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="name5" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">钱包密码</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="mima3" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <button type="button" class="layui-btn layui-btn-normal" id="import_key">导入私钥</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">钱包</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="qianbao5" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>列出所有钱包</legend>
                    <div class="layui-form-item">
                        <button type="button" class="layui-btn layui-btn-normal" id="wallet_list">列出所有钱包</button>
                        <label class="layui-form-label" style="width: 175px">钱包</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="qianbao6" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>列出所有钱包中的所有密钥对</legend>
                    <div class="layui-form-item">
                        <button type="button" class="layui-btn layui-btn-normal" id="list_keys">列出所有密钥对</button>
                        <label class="layui-form-label" style="width: 175px">密钥对</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="mimadui" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>列出所有钱包中的所有公钥</legend>
                    <div class="layui-form-item">
                        <button type="button" class="layui-btn layui-btn-normal" id="get_public_keys">列出所有公钥</button>
                        <label class="layui-form-label" style="width: 175px">公钥</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="gongyao" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>设置钱包自动锁定超时（以秒为单位）</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">时间</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="timeout" class="layui-input">
                        </div>
                        <button type="button" class="layui-btn layui-btn-normal" id="set_timeout">设置</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">钱包</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="qianbao7" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>
<script src="./plugins/layui/layui.js"></script>
<script src="./js/config.js"></script>
<script>
    layui.use(['table','form','element'],function () {
        var $ = layui.$;
        var table = layui.table;
        var form = layui.form;
        var element = layui.element;

        $('#create').on('click',function (){
            var data = {};
            data = $('input[name="name1"]').val();
            $.ajax({
                url: contextPath2+"wallet/create",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                data:data,
                success:function (data) {
                    $('input[name="mima"]').attr("value",data);
                },
                error:function () {
                }
            });
        });

        $('#open').on('click',function (){
            var data = {};
            data = $('input[name="name2"]').val();
            $.ajax({
                url: contextPath2+"wallet/open",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                data:data,
                success:function (data) {
                    $('input[name="qianbao"]').attr("value",data);
                },
                error:function () {
                }
            });
        });

        $('#lock').on('click',function (){
            var data = {};
            data = $('input[name="name3"]').val();
            $.ajax({
                url: contextPath2+"wallet/lock",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                data:data,
                success:function (data) {
                    $('input[name="qianbao2"]').attr("value",data);
                },
                error:function () {
                }
            });
        });

        $('#lock_all').on('click',function (){
            $.ajax({
                url: contextPath2+"wallet/lock_all",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                success:function (data) {
                    $('input[name="qianbao3"]').attr("value",data);
                },
                error:function () {
                }
            });
        });

        $('#unlock').on('click',function (){
            var data = [];
            data[0] = $('input[name="name4"]').val();
            data[1] = $('input[name="mima2"]').val();
            $.ajax({
                url: contextPath2+"wallet/unlock",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                data:data,
                success:function (data) {
                    $('input[name="qianbao4"]').attr("value",data);
                },
                error:function () {
                }
            });
        });

        $('#import_key').on('click',function (){
            var data = [];
            data[0] = $('input[name="name5"]').val();
            data[1] = $('input[name="mima3"]').val();
            $.ajax({
                url: contextPath2+"wallet/import_key",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                data:data,
                success:function (data) {
                    $('input[name="qianbao5"]').attr("value",data);
                },
                error:function () {
                }
            });
        });

        $('#wallet_list').on('click',function (){
            $.ajax({
                url: contextPath2+"wallet/wallet_list",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                success:function (data) {
                    $('input[name="qianbao6"]').attr("value",data);
                },
                error:function () {
                }
            });
        });

        $('#list_keys').on('click',function (){
            $.ajax({
                url: contextPath2+"wallet/list_keys",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                success:function (data) {
                    $('input[name="mimadui"]').attr("value",data);
                },
                error:function () {
                    alert('fail');
                }
            });
        });

        $('#get_public_keys').on('click',function (){
            $.ajax({
                url: contextPath2+"wallet/get_public_keys",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                success:function (data) {
                    $('input[name="gongyao"]').attr("value",data);
                },
                error:function () {
                }
            });
        });

        $('#set_timeout').on('click',function (){
            var data;
            data = $('input[name="timeout"]').val();
            $.ajax({
                url: contextPath2+"wallet/set_timeout",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                success:function (data) {
                    $('input[name="qianbao7"]').attr("value",data);
                },
                error:function () {
                }
            });
        });

    });
</script>
</body>
</html>